<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib prefix="s" uri="/struts-tags"%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<script src="js/jquery.js">
</script>
<script>
var request;
function read(message_id){
	request=new XMLHttpRequest();
	request.open("post","readmessage.action?message_id="+message_id,true);
	request.send();
	request.onreadystatechange=display;
}
function display(){
	document.getElementById('loader').innerHTML=request.responseText;
	//reload();
}
function reload(){
	
}

</script>
<script language="JavaScript">
$(document).ready(function()
		{
	$('#search').keyup(function()
		    {
		        searchTable($(this).val());
		    });
		});

</script>
<script>
function PopupCenter(pageURL, title,w,h) {
var left = (screen.width/2)-(w/2);
var top = (screen.height/2)-(h/2);
var targetWin = window.open (pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
} 
function searchTable(inputVal)
{
    var table = $('#example');
    table.find('tr').each(function(index, row)
    {
        var allCells = $(row).find('td');
        if(allCells.length > 0)
        {
            var found = false;
            allCells.each(function(index, td)
            {
                var regExp = new RegExp(inputVal, 'i');
                if(regExp.test($(td).text()))
                {
                    found = true;
                    return false;
                }
            });
            if(found == true)$(row).show();else $(row).hide();
        }
    });
}
</script>
<style type="text/css">
a{
	text-decoration:none 
}
a:LINK {
	color: #009ACD;
	
}

a:VISITED {
	color: #009ACD;
	
}
a:ACTIVE {
	color: black;
}

a:HOVER {
	color: red;
}
#shade{
	position:fixed;
	right:830px;
	top:99px;
	bottom:25px;
}
#shade1{
	position:fixed;
	right:810px;
	top:95px;
	bottom:25px;
}
#mes{
	background-color: white;
}
#mes:HOVER {
	background-color: #F1F1FA;
}
#mes:ACTIVE {
	background-color: #F1F1FA;
}
.scrollable { width:343px; height:500px; overflow-y:auto; overflow-x:auto; clip-rect:(0px, 343px, 500px, 0px); }
</style>
</head>
<body>


<div align="left">

<table><tr><td  width="1060" id="top" valign="top">
		<a href="javascript:void(0);" onclick="PopupCenter('./admin/NewMessage.jsp','batch',600,900);"><font style="font-size: small;"><img alt="" src="images/plus.png">New</font></a>
		&emsp;
			<s:url id="url4" action="inbox"></s:url>
			<s:a href="%{url4}"><font style="font-size: small;"><img alt="" src="images/inbox_green.jpg">Inbox
			
			
				</font>&ensp;<font color="white" style="background-color: #EE2C2C; font-family: calibri; font-size: small; font-weight: bold;">&ensp;<s:property value="inbox_count"/>&ensp;</font></s:a>
				&emsp;
				<s:url id="url3" action="starred_message_student"></s:url>
				<s:a href="%{url3}"><font style="font-size: small;"><img alt="" src="images/starred.jpg">Starred</font>
				&ensp;<font color="white" style="background-color: #EE2C2C; font-family: calibri; font-size: small; font-weight: bold;">&ensp;<s:property value="starred_count"/>&ensp;</font></s:a>
				&emsp;
				<s:url id="url1" action="sent_message_student"></s:url>
				<s:a href="%{url1}"><font style="font-size: small;"><img alt="" src="images/sent_msg.jpg">Sent</font>
				&ensp;<font color="white" style="background-color: #EE2C2C; font-family: calibri; font-size: small; font-weight: bold;">&ensp;<s:property value="sent_count"/>&ensp;</font></s:a>
				&emsp;
				<s:url id="url2" action="unread_message_student"></s:url>
				<s:a href="%{url2}"><font style="font-size: small;"><img alt="" src="images/unread.jpg">Unread</font>
				&ensp;<font color="white" style="background-color: #EE2C2C; font-family: calibri; font-size: small; font-weight: bold;">&ensp;<s:property value="unread_count"/>&ensp;</font></s:a>
				&emsp;
				<s:url id="url5" action="read_message_student"></s:url>
				<s:a href="%{url5}"><font style="font-size: small;"><img alt="" src="images/read.jpg">Read</font>
				&ensp;<font color="white" style="background-color: #EE2C2C; font-family: calibri; font-size: small; font-weight: bold;">&ensp;<s:property value="read_count"/>&ensp;</font></s:a>
				&emsp;
				<s:url id="url6" action="deleted_message_student"></s:url>
				<s:a href="%{url6}"><font style="font-size: small;"><img alt="" src="images/trash.jpg">Deleted</font>
				&ensp;<font color="white" style="background-color: #EE2C2C; font-family: calibri; font-size: small; font-weight: bold;">&ensp;<s:property value="deleted_count"/>&ensp;</font></s:a></td>
				<!-- 
				<td width="300" align="right"><img alt="" src="images/search.png"><input type="text" name="search" id="search" size="30" />
		
				-->
				<td width="400" align="right" valign="top">
				<form action="message_search_student.action">
					<select name="filter">
<option value="To">To</option>
<option value="From">From</option>
<option value="Subject">Subject</option>
<option value="Body">Body</option>
</select>
<input type="text" height="2px" name="search_box" size="20" />
				<input type="submit" value="Search">
				</form>
				
		</td>
		</tr></table>

</div>
	
	<hr>
	
	<table border="1" width="100%" id="example">
		<tr>
			<td width="30%">
			<div class="scrollable">
				<table width="100%">
					<s:iterator value="unread">
						<div onclick="openmessage()" id="<s:property value="message_id"/>" style="display: block;cursor:pointer;">
							<tr><td id="mes" onclick="read('<s:property value="message_id"/>')"><table width="100%">
							<tr><td height="5px"></td></tr>
							<tr>
							<s:if test="read_flag==1">
                    <td><font color="black" style="font-family: arial; font-size: 9pt;">&ensp;<img alt="" src="images/read_msg.png"> <s:property
												value="subject" /></font></td>
                        </s:if>
                    <s:else>
								<td><b><font color="black" style="font-family: arial; font-size: 10pt;">&ensp;<img alt="" src="images/inbox_green.jpg"><s:property
												value="subject" /></font></b></td>
												</s:else>
								<td align="right"><font color="gray" style="font-family: arial; font-size: x-small;">
								
								<s:if test="attachment_count==0"></s:if>
								<s:else><img alt="" src="images/attachment.jpg"> 
								
								&ensp;<s:property
											value="attachment_count" /></s:else> </font>&ensp;</td>
							</tr>
							<tr><td height="5px"></td></tr>
							<tr>
								<td><font color="gray" style="font-family: arial; font-size: 9pt;">&ensp;<i><s:property
												value="sender_id" /></i></font>
												
												</td>
								<td align="right"><font color="gray" style="font-family: arial; font-size: x-small;"><s:property value="sent_at"/> </font>&ensp;</td>				
											
							</tr>
							<tr><td align="right" colspan="2">
							<s:url id="url7" action="delete_message_unread_student">
								<s:param name="message_id"><s:property value="message_id"/></s:param>
							</s:url>
				<s:a href="%{url7}"><font style="font-size: x-small;">Delete</font></s:a>&emsp;
				
				
				
				<s:if test="starred_flag==1">
				<s:url id="url8" action="unstar_message_unread_student">
								<s:param name="message_id"><s:property value="message_id"/></s:param>
							</s:url>
				<s:a href="%{url8}"><font style="font-size: x-small;"><img alt="" src="images/starred_msg.jpg">&ensp; </font></s:a>
				</s:if>
				<s:else>
					<s:url id="url8" action="star_message_unread_student">
								<s:param name="message_id"><s:property value="message_id"/></s:param>
							</s:url>
				<s:a href="%{url8}"><font style="font-size: x-small;"><img alt="" src="images/unstar.png">&ensp; </font></s:a>
				</s:else>
							</td></tr>
							<tr><td colspan="2" style="border-bottom: 1px solid gray"></td></tr>
							</table></td></tr>
						</div>
					</s:iterator>
					<!-- 
					<s:iterator value="unread">
						<div onclick="openmessage()" id="<s:property value="message_id"/>" style="display: block;cursor:pointer;">

							<tr>
								<td><font color="black" style="font-family: arial; font-size: small;"><b><s:property
												value="subject" /></b></font></td>
								<td align="right"><font color="gray" style="font-family: arial; font-size: x-small;">Attachments:&ensp;<s:property
											value="attachment_count" /> </font></td>
							</tr>
							<tr>
								<td><font color="gray" style="font-family: arial; font-size: small;"><i><s:property
												value="sender_id" /></i></font>
												
												</td>
								<td align="right"><font color="gray" style="font-family: arial; font-size: x-small;"><s:property value="sent_at"/> </font></td>				
											
							</tr>
							<tr><td align="right" colspan="2"><a href="#" onclick="read('<s:property value="message_id"/>')"><font style="font-size: x-small;">Read</font></a>&emsp;
							<a href="#"><font style="font-size: x-small;">Delete</font></a>&emsp;<a href="#"><font style="font-size: x-small;">Star</font></a></font>
							</td></tr>
							<tr><td colspan="2" style="border-bottom: 1px solid gray"></td></tr>
						
						</div>
					</s:iterator>
					<s:iterator value="read">
						<div onclick="openmessage()" id="<s:property value="message_id"/>" style="display: block;cursor:pointer;">

							<tr>
								<td><font color="black" style="font-family: arial; font-size: small;"><s:property
												value="subject" /></font></td>
								<td align="right"><font color="gray" style="font-family: arial; font-size: x-small;">Attachments:&ensp;<s:property
											value="attachment_count" /> </font></td>
							</tr>
							<tr>
								<td><font color="gray" style="font-family: arial; font-size: small;"><i><s:property
												value="sender_id" /></i></font>
												
												</td>
								<td align="right"><font color="gray" style="font-family: arial; font-size: x-small;"><s:property value="sent_at"/> </font></td>				
									
							</tr>
							
							<tr><td align="right" colspan="2"><a href="#" onclick="read('<s:property value="message_id"/>')"><font style="font-size: x-small;">Read</font></a>&emsp;
							<a href="#"><font style="font-size: x-small;">Delete</font></a>&emsp;<a href="#"><font style="font-size: x-small;">Star</font></a></font>
							</td></tr>
							<tr><td colspan="2" style="border-bottom: 1px solid gray"></td></tr>
						
						</div>
					</s:iterator>
					 -->
				</table>
				</div>
			</td>
			
			<td id="shade" width="1%" style="background-image: url('./images/shade1_right.png'); background-repeat: repeat;"></td>	
			
		<td width="65%">	<table>
		
				<tr>
					<td width="100%"><div id="loader"></div></td>
				</tr>

			</table>
		</td>
		</tr>
	</table>
</body>
</html>